﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AvaloniaNotes.Models
{
    public class Note
    {
        /// <summary>
        /// 便签ID
        /// </summary>
        public int NoteId { get; set; }

        /// <summary>
        /// 便签内容
        /// </summary>
        public string Content { get; set; } = string.Empty;

        /// <summary>
        /// 便签颜色
        /// </summary>
        public string Color { get; set; } = "#FFFFFF";

        /// <summary>
        /// 标签颜色反色
        /// </summary>
        public string BtnColor { 
            get 
            {
                int sum = 0;
                string tempColor = Color.Remove(0, 1);
                for (int i = 0; i < tempColor.Length; i += 2)
                {
                    if ((tempColor.Length - i) > 2)//如果是，就截取
                    {
                        sum += Convert.ToInt32(tempColor.Substring(i, 2), 16);
                    }
                    else
                    {
                        sum += Convert.ToInt32(tempColor.Substring(i, 2), 16);
                    }
                }
                if (sum / tempColor.Length * 2 > 128)
                    return "#2F4F4F";
                return "#DCDCDC";
            } 
        }
        /// <summary>
        /// 是否删除
        /// </summary>
        public bool DeleteMark { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime? CreatedTime { get; set; } = DateTime.Now;

        /// <summary>
        /// 更新时间
        /// </summary>
        public DateTime? UpdatedTime { get; set; }
    }
}
